# installs necessary packages
install.packages("ggthemes")
library(ggthemes)
library(ggplot2)

# set working director here
setwd("F:\\awei\\Spring\\Data\\Replication data\\Submission files\\data")

# reads in data
data = read.csv(file = "scatter.csv")

# Figure 3A part a
ggplot(data, aes(x = data$ques1, y = data$SEXISM)) + geom_point() + geom_smooth(method = "lm", se = FALSE) + geom_text(aes(label=data$state_name, hjust = -.4, vjust = .4), size = 2.5) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
                                                                                                                                                                                                panel.background = element_blank(), axis.line = element_line(colour = "black"),
                                                                                                                                                                                                axis.title.y = element_text(margin = margin(t = 0, r = 10, b = 0, l = 0)),
                                                                                                                                                                                                axis.title.x = element_text(margin = margin(t = 10, r = 0, b = 0, l = 0)),
                                                                                                                                                                                                axis.title=element_text(size=12.5),
                                                                                                                                                                                                plot.title = element_text(hjust = 0.5)) + xlab("Do women often fail to appreciate what men do for them?") + ylab("Google Sexism Index") + ggtitle("(a) Absolute") + annotate("label", x = max(data$ques1)-.1, y = min(data$SEXISM), label = "t = 1.78*")

# Figure 3A part b
ggplot(data, aes(x = data$ques1_rank, y = data$SEXISM_rank)) + geom_point() + geom_smooth(method = "lm", se = FALSE) + geom_text(aes(label=data$state_name, hjust = -.4, vjust = .4), size = 2.5) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
                                                                                                                                                                                              panel.background = element_blank(), axis.line = element_line(colour = "black"),
                                                                                                                                                                                              axis.title.y = element_text(margin = margin(t = 0, r = 10, b = 0, l = 0)),
                                                                                                                                                                                              axis.title.x = element_text(margin = margin(t = 10, r = 0, b = 0, l = 0)),
                                                                                                                                                                                              axis.title=element_text(size=12.5),
                                                                                                                                                                                              plot.title = element_text(hjust = 0.5)) + xlab("Do women often fail to appreciate what men do for them?") + ylab("Google Sexism Index") + ggtitle("(b) Rank") + annotate("label", x = max(data$ques1_rank)-.1, y = min(data$SEXISM_rank), label = "t = 1.70*")
# Figure 3B part a
ggplot(data, aes(x = data$ques2, y = data$SEXISM)) + geom_point() + geom_smooth(method = "lm", se = FALSE) + geom_text(aes(label=data$state_name, hjust = -.4, vjust = .4), size = 2.5) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
                                                                                                                                                                                                        panel.background = element_blank(), axis.line = element_line(colour = "black"),
                                                                                                                                                                                                        axis.title.y = element_text(margin = margin(t = 0, r = 10, b = 0, l = 0)),
                                                                                                                                                                                                        axis.title.x = element_text(margin = margin(t = 10, r = 0, b = 0, l = 0)),
                                                                                                                                                                                                        axis.title=element_text(size=12.5),
                                                                                                                                                                                                        plot.title = element_text(hjust = 0.5)) + xlab("Do women often consider innocent remarks sexist?") + ylab("Google Sexism Index") + ggtitle("(a) Absolute") + annotate("label", x = max(data$ques2)-.1, y = min(data$SEXISM), label = "t = 2.53**")


# Figure 3B part b
ggplot(data, aes(x = data$SEXISM_rank, y = data$ques2_rank)) + geom_point() + geom_smooth(method = "lm", se = FALSE) + geom_text(aes(label=data$state_name, hjust = -.4, vjust = .4), size = 2.5) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
                                                                                                                                                                                               panel.background = element_blank(), axis.line = element_line(colour = "black"),
                                                                                                                                                                                               axis.title.y = element_text(margin = margin(t = 0, r = 10, b = 0, l = 0)),
                                                                                                                                                                                               axis.title.x = element_text(margin = margin(t = 10, r = 0, b = 0, l = 0)),
                                                                                                                                                                                               axis.title=element_text(size=12.5),
                                                                                                                                                                                               plot.title = element_text(hjust = 0.5)) + xlab("Do women often consider innocent remarks sexist?") + ylab("Google Sexism Index") + ggtitle("(b) Rank") + annotate("label", x = max(data$SEXISM_rank)-2, y = min(data$SEXISM_rank), label = "t = 2.97***")


